If you have not yet read the IG AppleScript Intro file, please do that before going on with this one.
Events
Events are arranged into functional categories. Keywords for parameters are italicized in the text below. For an alphabetical listing, look at the dictionary in Script Editor.
Current Record-related Events
These events operate only on the current record of the current (front-most) datafile. They often involve the selection of text, and or the movement of text to and from the clipboard.
clear - Clears selected text in the current datafile without moving it into the clipboard.
copy - Copies the selection in the current datafile to the clipboard.
cut - Cuts the selection from the current datafile to the clipboard.
display - Brings a record and/or datafile to the front, making it the current record or datafile. This also makes that record/datafile the default for many other events.
This event requires a reference to a record or to a datafile. If the reference is a record, that record is made current, and so is its datafile. If the reference is a datafile, it is brought to the front without changing its current record.
Examples: display record 5 of datafile "Sample Field Datafile"
display datafile "Recipes"
display record 3 -- of the current datafile
find - Searches for the next record containing a specified string. First, the datafile being searched is brought to the front. If the string is found, its record is made the current record, the string is selected, and the event returns a result of true. If the search is unsuccessful, the result is false. (In the case of field-based datafiles, the selection will not go past the end of the first cell containing the found text.)
This event takes an optional keyword in, followed by a reference to a datafile. If there is no reference, the default is to search the current datafile.
If the search was successful, you can get the offset and length of the selected string by using the get data event to get the datafile's selection start and selection length properties.
To search for more than one string, place \"AND\" between the strings inside the main quotes. See the second example below.
Examples: find "Bob Farkle" -- in the current datafile
find "pepper\"AND\"mango" in datafile "Recipes"
if find "Mackintosh" in datafile "Bogus Data"
set selection to "Macintosh"
end if
paste - Pastes the contents of the clipboard to the selection in the current datafile.
record snapshot - Copies the current record, including field names, if any, into the clipboard.
select all - Selects all current text. If the Find Box is active, all the text in it will be selected. If the Text Area is active, the result varies with the type of datafile. If it is freeform, the entire text will be selected. If it is field-based, all the text in the field that contains the current selection will be selected. The latter is done to help prevent the inadvertent deletion of carriage returns, which are used to separate the fields.
select cell - Selects the text in a cell in the current record of the current datafile.
This event takes a string containing the name of the cell as a required parameter.
Example: select cell "Notes" -- in the current record of the current datafile
Data Extraction Events
count - Returns the number of elements of a particular class within an object.
This event requires both a reference to the object whose elements are to be counted, and to the type class of the elements being counted. The type class may optionally be preceded by the keyword each. The object whose elements are to be counted is preceded by the word in.
Examples: count record 2 of datafile "Sample Field Datafile" each word
count words in paragraph 2 of record 3
count records in datafile "Sample Freeform Datafile"
count cells in datafile "Sample Field Datafile"
data size - Returns the size in bytes of an object. With languages other than Japanese, Chinese, and Korean, the size in bytes is the same as the number of characters.
This event requires a reference to the object whose size is being calculated.
exists - Verifies whether or not an object exists. Returns true is it exists, false if it doesn't.
This event requires a reference to the object in question.
Example: if paragraph 2 of record 1 exists then beep end if
get - Gets the data for an object. These may be either textual elements (characters, words, paragraphs, etc.) or properties (paragraph length, cell name, datafile name, InfoGenie version, etc.). The word get is optional.
This event requires a reference to the object whose data is to be returned.
In the case of properties, most text objects have only offset (from the start of the datafile) and length. Cells have name, the application has name and version, and datafiles have quite a list. See the section on Classes for more information.
Examples: -- following are elements
get word 1 of paragraph 3 of record 8 of datafile "Lawyer Jokes"
get cell "State" of every record of datafile "Sample Field Datafile"
get (paragraphs 2 thru 4) of every record of datafile "Sample Freeform Datafile"
get (text from character 1 to character 3) of every record
get (every word whose character 1 is "M") of record 1
get cell "Organization" of (every record whose cell "State" is "TX") of datafile 1
-- following are properties
get view of datafile "Sample Field Datafile" -- List View or Basic View
get text block of datafile "Sample Freeform Datafile"
get version of application "InfoGenie™"
set theLength to length of word 3
set firstCharacter to offset of word 3
set lastCharacter to firstCharacter + theLength - 1
get text from character firstCharacter to character lastCharacter
get current record of datafile 1
if field based datafile 2
get every cell of record 3 of datafile 2
end if
Data Insertion Events
duplicate - Duplicates a record. Returns a reference to the new record.
This event takes an optional a reference to the record that is to be duplicated. If there is no reference, the default is the current record of the current datafile. The datafile containing the object to be duplicated is first brought to the front, becoming the current datafile.
It also takes an optional reference to the record before which or after which the duplicate is to be inserted. The default is to insert the duplicate immediately after the record which is being duplicated.
Examples: duplicate record 3 -- duplicate at 4
duplicate record 3 at end of last record -- duplicate at end of datafile
duplicate record 3 at beginning of first record -- duplicate at 1
duplicate record 3 at end of record 4 -- duplicate at 5
duplicate record 3 at beginning of record 2 -- duplicate at 2
import Email - Imports an E-mail text file into the current freeform datafile. You can use the display event to bring a datafile to the front before calling this event.
This event requires an alias or full pathname of the E-mail text file that is being imported, or a list of such aliases.
It also takes an optional parameter consisting of the name of the E-mail format preceded by the keyword with format. The format name must be one of the ones that appears in the Import E-mail dialog. If there is no with format parameter, the default format is used.
It also takes an optional true or false parameter preceded by the keyword prepend. If the parameter is true, the imported E-mail messages will be inserted at the beginning of the datafile. If it is false, they will be inserted at the end of the datafile. The default is false.
Example: display datafile "January 1995 E-Mail"
import Email "Hard Disk:E-Mail Folder:Email from Jan 95"
import Email "Hard Disk:E-Mail Folder:Late Jan 95 Email" with format ¬
"SnapMail™ 2.0 Text File" prepend false
import text as record - Appends a text file as a record in the current freeform datafile. You can use the display event to bring a datafile to the front before calling this event.
This event requires an alias or full pathname of the text file that is being imported, or a list of such aliases.
Example: display datafile "Recipes"
import text as record "Hard Disk:Recipe Folder:Potato Salad Recipe"
make - Makes a new record optionally at a specified location and with specified data. Returns a reference to the new record. The datafile where the object is to be created is first brought to the front, becoming the current datafile.
This event requires the word record, optionally preceded by the word new.
It also takes an optional reference to the record before which or after which the new record is to be inserted. The default is to insert the new record at the end of the current datafile.
It also takes an optional parameter, following the keyword with data, to some textual data. The data may be a single text object or a list of text objects. If the datafile is freeform, all the data is simply placed into the record as it is. If the datafile is field-based and the data is a list, then each item of the list is inserted in turn into a cell of the record. If there are more items in the list than there are cells, all remaining items are inserted into the last cell of the record, just as they would go into a freeform record. If the with data parameter is omitted, the result is an empty record. (Note that empty records are deleted whenever you change records or close the datafile, so some kind of data must be inserted in order to avoid automatic deletion.)
Examples: make record at end of record 3 of datafile 1 with data {"Ms.", "Katy", "Deere"}
make record at beginning of record 1 with data "This is record 1."
make new record -- make empty record at end of current datafile
set - Sets an object's data. If the object is a block of text, it is replaced. If the object is an insertion point, the data is inserted at that point. If the object is a property, the value of that property is changed. The datafile containing the object to be changed is first brought to the front, becoming the current datafile.
This event requires a reference to the object that is to be changed and a parameter, following the keyword new, containing the new value.
Examples: -- following are elements
set word 1 of paragraph 2 of record 12 to "Abraham"
set insertion point before word 2 to "("
set insertion point after word 2 to ")"
set {word 1, word 2, word 3} to {"one", "two", "three"}
try
set insertion point before (every word whose character 1 is "M") to "M-M-"
on error
end try
set cell "State" of (every record whose cell "State" is "TX") to "Texas"
set every word where it is "TX" to "Texas"
set every cell of every record to ""
-- following are properties
find "Microsoft is great."
set selection to "The Evil Empire is large."
set view to basic view
set font of datafile "Sample Freeform Datafile" to "Helvetica"
set size to 12
set style to plain
set style to {bold, italic}
tell record 4
set {cell "First", cell "Last", cell "State"} to {"Mary Jo", "Smith", "AZ"}
end tell
Data Modification Events
delete - Deletes an element from an object.
This event requires a reference to the element that is to be deleted.
Examples: delete character 1 of record 1 of datafile "Sample Freeform Datafile"
delete cell "Position" of every record of datafile 1
delete last record -- of the current datafile
move - Moves a record to a new location. Returns a reference to the object in its new location. The datafile containing the object to be moved is first brought to the front, becoming the current datafile.
This event requires a reference to the record that is to be moved, and a reference to the record before or after which it is being moved.
Examples: move record 3 to end of record 6 of datafile 1 -- becomes 6
move record 3 to beginning of record 1 -- becomes 1
move record 3 -- moves it after itself, so does nothing
File-related Events
close - Closes a datafile.
This event takes an optional reference to the datafile that is to be closed. If there is no reference, the default is the current datafile.
It also takes an optional parameter following the keyword saving. If the parameter is yes, any changes are saved. If it is no, changes are not saved. If it is ask, a dialog comes up that requires user interaction. If there is no parameter, the default is ask.
Examples: close -- close the current datafile. Bring up dialog if there have been changes.
close datafile "Recipes" saving ask
close datafile "Recipes" saving yes
close datafile "Recipes" saving no
open - Opens the specified file(s).
This event requires an alias (or list of aliases) to the file(s) to be opened. This is most useful when using a scripting extension which brings up a dialog permitting the user to select a datafile, and which then returns an alias to the datafile in the result.
Example: open "Hard Drive:InfoGenie™ Folder:Datafiles:Recipes"
open datafile - Opens a datafile using its name from the Datafiles menu. Returns true if the datafile was successfully opened. Otherwise, returns false, which could happen if the name does not appear in the Datafiles menu.
This event requires the name of the datafile just as it appears in the Datafiles menu, but it does NOT require a full path name or alias. This is generally more convenient than the standard open event when no user interaction is desired.
Example: open "Recipes"
quit - Quits InfoGenie.
This event takes an optional parameter following the keyword saving. If the parameter is yes, any changes are saved. If it is no, changes are not saved. If it is ask, a dialog comes up that requires user interaction. If there is no parameter, the default is ask.
Examples: quit -- bring up save dialog if there have been changes
quit saving yes
quit saving no
revert - Reverts to saved version of a datafile.
This event takes an optional parameter to the datafile that is to be reverted. The default is to revert the current datafile.
Examples: revert -- the current datafile
revert datafile "U.S. Senators"
save - Saves a datafile.
This event takes an optional parameter to the datafile that is to be saved. The default is to save the current datafile.
Examples: save -- the current datafile
save datafile "U.S. Senators"
Printing Events
The use of a single print command would require a large number of complex parameters and default behaviors. Instead, we have decided to provide more specific routines for those printing options that we are going to support.
print - This event is included to comply with support for the Required Suite, but it actually does nothing, because there is no appropriate default printing behavior for InfoGenie.
print current - Makes a record current and prints it.
This event takes an optional reference to a record to be printed. If there is no reference, the default is the current record of the current datafile.
Examples: find "Fred Farkle" in "Sample Freeform Datafile"
print current -- the current record, containing info on Fred Farkle
print current record 5 of datafile "Recipes"
print quick envelope - Makes a record current and prints a single envelope using the text block from that record. The text block is set for each datafile using the Text Block Layout function (under the Edit menu in Basic View).
This event takes an optional reference to a record containing the address (text block) to be printed. If there is no reference, the default is the current record of the current datafile.
It also takes an optional parameter following the keyword with template, which is the name of the envelope template which is to be used.
Examples: print quick envelope -- using the current record
print quick envelope record 6 of datafile "Sample Field Datafile"
print quick envelope record 5 with template "4.125 X 9.25 w/return address"
Sorting Events
As with printing, the use of a single sort command would require a large number of complex parameters and default behaviors. Instead, we have decided to provide more specific routines for the various sorting options. Each event has its own appropriate parameters. Note that all the sorts default to ascending textual sorts using whatever other criteria were last used when sorting that datafile.
sort field based - Sorts the records in a field-based datafile. The datafile containing the object to be sorted is first brought to the front, becoming the current datafile.
This event takes an optional reference to the datafile to be sorted. It must be a field-based datafile. If there is no reference, the default is to sort the current datafile.
It also takes any or all of the following optional parameters, preceded by the appropriate keywords:
primary reference -- primary cell to sort on - default is current primary cell
secondary reference -- secondary cell to sort on - default is none (no secondary sort)
in order ascending/descending -- the sort order - default is ascending
primary as textual/numeric -- the primary sort type - default is textual
secondary as textual/numeric -- the secondary sort type - default is textual
Examples: sort field based datafile "Sample Field Datafile" primary cell "Last" secondary¬
cell "First" in order descending
sort field based datafile "Customer Info" primary cell "Index" primary as numeric
sort names - Sorts the records in a freeform datafile by last name and secondarily by first name. Identification of the last name is simply the last word which is not a title. Surnames such as De La Rosa and van Buren are not recognized as single names. The datafile containing the object to be sorted is first brought to the front, becoming the current datafile.
This event takes an optional reference to the datafile to be sorted. It must be a freeform datafile. If there is no reference, the default is to sort the current datafile.
It also takes either or both of the following optional parameters, preceded by the appropriate keyword:
onLine integer -- number of line containing names (-1 means last line of record, 0 [zero] means last line of address block) - default is current setting
in order ascending/descending -- the sort order - default is ascending
Examples: sort names datafile "Sample Freeform Datafile" onLine 1 in order ascending
sort names datafile "Japanese Customers" onLine 0
sort whole records- Sorts the records in a freeform datafile by whole record. The datafile containing the object to be sorted is first brought to the front, becoming the current datafile.
This event takes an optional reference to the datafile to be sorted. It must be a freeform datafile. If there is no reference, the default is to sort the current datafile.
It also takes an optional parameter, preceded by the keyword in order, which indicates whether the sort is to be ascending or descending. If there is no parameter, the default is to sort in ascending order.
Example: sort whole record datafile "Recipes" in order ascending
sort WOL - Sorts the records in a freeform datafile by word # on line #. The datafile containing the object to be sorted is first brought to the front, becoming the current datafile. WOL is short for "Word On Line".
This event takes an optional reference to the datafile to be sorted. It must be a freeform datafile. If there is no reference, the default is to sort the current datafile.
It also takes any or all of the following optional parameters, preceded by the appropriate keyword:
byWord integer -- number of the word (within its line) to sort on (-1 means last word)- default is current setting
onLine integer -- number of line containing names (-1 means last line of record, 0 [zero] means last line of address block) - default is current setting
in order ascending/descending -- the sort order - default is ascending
sort WOL datafile 2 byWord -1 onLine -1 -- by last word on last line of records
sort zip codes - Sorts the records in a freeform datafile by Zip Code. The sorted datafile will have all records that do not contain recognized postal codes, followed by those containing U.S. Zip code in order, and then by those containing Canadian postal codes in order. The datafile containing the object to be sorted is first brought to the front, becoming the current datafile.
This event takes an optional reference to the datafile to be sorted. It must be a freeform datafile. If there is no reference, the default is to sort the current datafile.
It also takes an optional parameter, preceded by the keyword in order, which indicates whether the sort is to be ascending or descending. If there is no parameter, the default is to sort in ascending order.
Example: sort zip codes "Sample Freeform Datafile"
Classes
See the IG AppleScript Classes file for information on object classes supported by InfoGenie.